package com.fenghuajueli.lib_pictureselect.config;

import android.content.Intent;

import com.fenghuajueli.lib_pictureselect.entity.SelectMediaEntity;
import com.fenghuajueli.lib_pictureselect.PhotoSelectorBuilder;
import com.fenghuajueli.lib_pictureselect.activity.PictureSelectActivity;
import com.fenghuajueli.lib_pictureselect.interfaces.OnSelectResultListener;

import java.util.List;

public class PhotoSelectMode {

    private PhotoConfig photoConfig;
    private PhotoSelectorBuilder photoSelectorBuilder;

    public PhotoSelectMode(PhotoConfig.Mode mode, PhotoSelectorBuilder photoSelectorBuilder) {
        this.photoConfig = PhotoConfig.getInstance(true);
        this.photoConfig.setMode(mode);
        this.photoSelectorBuilder = photoSelectorBuilder;
    }


    public PhotoSelectMode maxCount(int maxCount) {
        photoConfig.setMaxCount(maxCount);
        return this;
    }


    public PhotoSelectMode minCount(int minCount) {
        photoConfig.setMinCount(minCount);
        return this;
    }

    /**
     * 是否拷贝到app私有目录下，有些情况下或第三方sdk没有适配安卓10的话 可以先打开考呗到私有目录来访问
     * @param isCopy
     * @return
     */
    public PhotoSelectMode isCopyToPrivate(boolean isCopy) {
        photoConfig.setCopyToPrivate(isCopy);
        return this;
    }


    public void listener(OnSelectResultListener<List<SelectMediaEntity>> onSelectResultListener) {
        photoConfig.setOnSelectResultListener(onSelectResultListener);
        Intent intent = new Intent(photoSelectorBuilder.getActivity(), PictureSelectActivity.class);
        photoSelectorBuilder.getActivity().startActivity(intent);
    }


}
